/*
 * @Author: dawei 664690250@qq.com
 * @Date: 2023-04-07 07:58:53
 * @LastEditors: dawei 664690250@qq.com
 * @LastEditTime: 2023-04-07 08:30:13
 * @FilePath: /hn-talent-ump-vue/src/components/gantt/components/Chart/Row/Task.mixin.js
 * @Description: 请填写文件描述
 * 大佬别走，带带弟弟
 * Copyright (c) 2023 by ${git_name_email}, All Rights Reserved.
 */
/**
 * @fileoverview Task mixin
 * @license MIT
 * @author Rafal Pospiech <neuronet.io@gmail.com>
 * @package GanttElastic
 */

export default {
  computed: {
    /**
     * Get view box
     *
     * @returns {string}
     */
    getViewBox() {
      const task = this.task
      return `0 0 ${task.width} ${task.height}`
    },

    /**
     * Get group transform
     *
     * @returns {string}
     */
    getGroupTransform() {
      return `translate(${this.task.x} ${this.task.y})`
    },

    /**
     * Should we display expander?
     *
     * @returns {boolean}
     */
    displayExpander() {
      const expander = this.root.state.options.chart.expander
      return expander.display || (expander.displayIfTaskListHidden && !this.root.state.options.taskList.display)
    }
  },
  methods: {
    /**
     * Emit event
     *
     * @param {string} eventName
     * @param {Event} event
     */
    emitEvent(eventName, event) {
      if (!this.root.state.options.scroll.scrolling) {
        this.root.$emit(`chart-${this.task.type}-${eventName}`, { event, data: this.task })
      }
    }
  }
}
